<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/pages/layout.xhtml">
	<ui:define name="conteudo">
		<h3>Minhas Contas</h3>
			
		<h:commandLink action="#{contasMBean.voltar}" value="Listagem" immediate="true"/>
		
		<br/><br/>
		
		<table cellspacing="10">
			<tr>
				<td><h:outputLabel value="Descrição:"/></td>
				<td><p:inputText value="#{contasMBean.obj.descricao}" size="40"/></td>
			</tr>
			
			<tr>
				<td><h:outputLabel value="Tipo de Conta:"/></td>
				<td>
					<p:selectOneMenu value="#{contasMBean.obj.tipo.id}">
						<f:selectItem itemLabel="-- SELECIONE --" itemValue=""/>
						<f:selectItems value="#{tipoContaMBean.tiposConta}"/>
					</p:selectOneMenu>
				</td>
			</tr>
			
			<tr>
				<td><h:outputLabel value="Grupo de Categoria:"/></td>
				<td>
					<p:selectOneMenu value="#{contasMBean.obj.categoria.grupo.id}">
						<f:selectItem itemLabel="-- SELECIONE --" itemValue=""/>
						<f:selectItems value="#{categoriaContaMBean.gruposCategoria}"/>
						<f:ajax event="change" execute="@this" render="categorias"/>
					</p:selectOneMenu>
				</td>
			</tr>
			
			<tr>
				<td><h:outputLabel value="Categoria:"/></td>
				<td>
					<p:selectOneMenu id="categorias" value="#{contasMBean.obj.categoria.id}">
						<f:selectItem itemLabel="-- SELECIONE --" itemValue=""/>
						<f:selectItems value="#{contasMBean.categorias}"/>
					</p:selectOneMenu>
				</td>
			</tr>
			
			<tr>
				<td><h:outputLabel value="Valor:"/></td>
				<td><p:inputText value="#{contasMBean.obj.valor}" size="10"/></td>
			</tr>
			
			<tr>
				<td><h:outputLabel value="Data:"/></td>
				<td><p:calendar value="#{contasMBean.obj.dataVencimento}" pattern="dd-MM-yyyy" mask="true"/></td>
			</tr>
			
			<tr>
				<td><h:outputLabel value="Situação:"/></td>
				<td>
					<p:selectOneMenu value="#{contasMBean.obj.situacao.id}">
						<f:selectItem itemLabel="-- SELECIONE --" itemValue=""/>
						<f:selectItems value="#{contasMBean.situacoes}"/>
					</p:selectOneMenu>
				</td>
			</tr>
			
			<tr>
				<td colspan="2" align="center">
					<p:commandButton value="Cadastrar" action="#{contasMBean.salvar}" rendered="#{contasMBean.obj.id == 0}" ajax="false"/>
					<p:commandButton value="Atualizar" action="#{contasMBean.atualizar}" rendered="#{contasMBean.obj.id > 0}" ajax="false"/>
				</td>
			</tr>
		</table>
	</ui:define>
</ui:composition>

</html>